package com.ocom.human.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ocom.common.entity.human.EntityPersonnelFaceFeature;
import com.ocom.common.request.human.FaceFeatureRequest;
import com.ocom.common.response.human.PerFaceFeatureResponse;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface IDaoPersonnelFaceFeature extends BaseMapper<EntityPersonnelFaceFeature> {

    @Select({"<script>",
            "select " +
                    " f.* ,CONCAT(f.photo,'?size=50') as photoCheck ," +
                    " p.p_code, p.p_name,p.status,CONCAT(p.p_photo_url2,'?size=50') as xfFace " +
                    " from personnel_face_feature f \n" +
                    " left join personnel_info p  on  p.com_id=f.com_id and p.p_id=f.p_id\n" +
                    " Where p.com_id=#{comId} " +
                    " <when test=\"status !=null \" > " +
                    " and p.status=#{status} " +
                    " </when>" +
                    " <when test=\"faceNum !=null \" > " +
                    " and f.face_num=#{faceNum} " +
                    " </when>" +
                    " <when test=\"pCode !=null  and  pName !='' \" > " +
                    " and p.p_code=#{pCode} " +
                    " </when>" +
                    " <when test=\"pName !=null  and  pName !='' \" > " +
                    " and p.p_name=#{pName} " +
                    " </when>" +
                    " <when test=\"minFaceProbability != null and minFaceProbability > 0\" > " +
                    " and f.face_probability &gt;= #{minFaceProbability}" +
                    " </when>" +
                    " <when test=\"minLandmark72Probability != null and minLandmark72Probability > 0\" > " +
                    " and f.landmark72_probability &gt;= #{minLandmark72Probability}" +
                    " </when>" +
                    " order  by" +
                    " <when test=\"orderByAsc =='minFaceProbability' \" > " +
                    " f.face_probability asc , " +
                    " </when>" +
                    " <when test=\"orderByAsc =='minLandmark72Probability' \" > " +
                    " f.landmark72_probability asc , " +
                    " </when>" +
                    " f.create_time  desc " +
                    "</script>"})
    List<PerFaceFeatureResponse> getPerFeature(FaceFeatureRequest request);

}
